package com.zz.parkingsystem.controller.admin;

import com.zz.parkingsystem.dto.InsFeedbackDTO;
import com.zz.parkingsystem.dto.UserFeedbackDTO;
import com.zz.parkingsystem.service.PCFeedBackService;
import com.zz.parkingsystem.util.Result;
import com.zz.parkingsystem.util.ResultGenerator;
import com.zz.parkingsystem.vo.InsFeedbackVO;
import com.zz.parkingsystem.vo.UserFeedbackVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/userfb")
@Api(tags = "反馈管理")
public class AdminFeedBackController {
    @Autowired
    private PCFeedBackService feedBackService;

    @PostMapping("/queryAllUserFB")
    @ApiOperation(value = "查询所有用户反馈订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每一页显示的条数", required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "currentPage", value = "当前页", required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "pageNum", value = "从那一页开始", required = false, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "dateRange", value = "日期范围", required = false, paramType = "query"),
            @ApiImplicitParam(name = "ufNo", value = "用户反馈单号", required = false, paramType = "query"),
    })
    public Result queryAllUserFB(@RequestBody UserFeedbackDTO userFeedbackDTO){
        userFeedbackDTO.setPageNum((userFeedbackDTO.getCurrentPage()-1)*userFeedbackDTO.getPageSize());
        List<UserFeedbackVO> userFeedbackVOS = feedBackService.queryAllUserFeedBack(userFeedbackDTO);
        Long total = feedBackService.getUserFBCount(userFeedbackDTO);
        Map map = new HashMap();
        map.put("userFeedbackVOS",userFeedbackVOS);
        map.put("total",total);
        return ResultGenerator.genSuccessResult(map);
    }

    @PostMapping("/queryAllInsFB")
    @ApiOperation(value = "查询所有巡检员反馈订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageSize", value = "每一页显示的条数", required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "currentPage", value = "当前页", required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "pageNum", value = "从那一页开始", required = false, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "dateRange", value = "日期范围", required = false, paramType = "query"),
            @ApiImplicitParam(name = "ifNo", value = "巡检员反馈单号", required = false, paramType = "query"),
    })
    public Result queryAllInsFB(@RequestBody InsFeedbackDTO insFeedbackDTO){
        insFeedbackDTO.setPageNum((insFeedbackDTO.getCurrentPage()-1)*insFeedbackDTO.getPageSize());
        List<InsFeedbackVO> insFeedbackVOS = feedBackService.queryAllInsFB(insFeedbackDTO);
        Long total = feedBackService.getInsFBCount(insFeedbackDTO);
        Map map = new HashMap();
        map.put("insFeedbackVOS",insFeedbackVOS);
        map.put("total",total);
        return ResultGenerator.genSuccessResult(map);
    }
}
